<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


<title>My notes</title>
<link rel="shortcut icon" href="__TMPL__Public/images/icon.png" />
<link type="text/css" rel="stylesheet" href="__TMPL__Public/css/common.css" media="all" />
<link type="text/css" rel="stylesheet" href="__TMPL__Index/css/index.css" media="all" />

<link type="text/css" rel="stylesheet" href="__TMPL__Public/jquery/css/le-frog/jquery-ui-1.8.16.custom.css" media="all"  />
<script type="text/javascript" src="__TMPL__Public/jquery/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="__TMPL__Public/jquery/js/jquery-ui-1.8.16.custom.min.js"></script>

<script type="text/javascript" src="__TMPL__Public/js/common.js"></script>

<script type="text/javascript">	
	$(function(){
		$(".buttons").button().css("font-size", "16px");
		
		$(".join_group_button").bind('click', function(){
			var group_id = $(this).attr('group_id');
			joinGroup(group_id,this);
		});
	});

function joinGroup(group_id, button){
        $.get(APP_PATH + "Group/join", {
            group_id: group_id
        }, function(result){
            result = JSON.parse(result);
			if(result.status == 1) {
				alert("已加入");
				$(button).val("进入");
				$(button).unbind('click');
				$(button).bind('click', function(){
					window.location = APP_PATH + "Group/groupPage?group_id=" + group_id;
				});
			}
        });
    }
</script>

</head>
<body id="index_item">
	<include file="Public:header"/>
	
	<div id="main_panel">
	
	<h2>新书列表</h2>
	
	<volist name="newest_books" id="book"> 
		<div class="each_book">
			<img src="{&UPLOAD_FILE_PATH_VIEW}{$book.picture}"  width="220px"/>
			<p>书名：{$book.title}</p>
			<p>所属小组：{$book.group.name}</p>
			<a href="__APP__/Book/showOneBook?book_id={$book.id}">详细</a>
		</div>
	</volist>
	
	<a class="buttons" id="show_all_books" href="__APP__/Book/showAllBooks">显示全部图书</a>
	
	<h2>小组……</h2>
	<volist name="newest_groups" id="group"> 
		<div class="each_group">
			<p>小组名：{$group.name}</p>
			<p>创立者：{$group.founder.name}</p>
			<in name="group.id" value="$user.group_ids" id="huhu">
				<a class="buttons" href="__APP__/Group/groupPage?group_id={$group.id}">进入</a>
			<else/>
			<div id="addtogroup">
				<input type="button" value="加入小组" class="join_group_button buttons" group_id="{$group.id}"/>
			</div>	
			</in>
		</div>
	</volist>
	<a class="buttons" id="show_all_groups" href="__APP__/Group/showAllGroups">显示全部小组</a>
	<a class="buttons" id="create_group" href="__APP__/Group/foundPage">创建小组</a>
	
	</div>

    <include file="Public:common"/>

</body>
</html>